package com.bw.controller;

import com.bw.bean.Sugar;
import com.bw.bean.Sugar1;
import com.bw.bean.Sugar2;
import com.bw.service.SugarService;
import com.sugar.SugarUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;

@RestController
public class SugarController {
    @Autowired
    SugarService sugarService;

    @RequestMapping("/list1")
    public Map getList1(){
        List<Sugar> list=sugarService.getList1();
        return SugarUtil.getLineData(list);
    }

    @RequestMapping("/list2")
    public Map getList2(){
        List<Sugar1> list=sugarService.getList2();
        List list1=new ArrayList();
        list1.add("课程名称");
        list1.add("考试人次");
        list1.add("平均分");
        list1.add("平均用时");
        return SugarUtil.getTablePlayData(list1,list);
    }

    @RequestMapping("/list3")
    public Map getList3(){
        Double list=sugarService.getList3();
        return SugarUtil.getFlipNumberData(list);
    }

    @RequestMapping("/list4")
    public Map getList4(){
        List<Sugar2> list=sugarService.getList4();
        List list1=new ArrayList();
        list1.add("课程名称");
        list1.add("平均评分");
        list1.add("评价人数");
        list1.add("好评人数");
        list1.add("好评率");
        return SugarUtil.getTablePlayData(list1,list);
    }
}
